package com.cfa.controller;

import com.cfa.mapper.UserMapper;
import com.cfa.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/getAllUser")
    public List<User> getAllUser(){
        List<User> users = userMapper.getAll();
        return users;
    }
    @RequestMapping("/gerUser")
    public User getUser(Long id){
        User user = userMapper.findById(id);
        return user;
    }
    @RequestMapping("/add")
    public void add(User user){
        userMapper.insert(user);
    }
    @RequestMapping("/update")
    public void update(User user){
        userMapper.update(user);
    }
    @RequestMapping("/delete")
    public void delete(Long id){
        userMapper.deleteById(id);
    }
}
